<template>
  <div class="page-container-padding">
    <!-- 查询参数选择 -->
      <span style="margin: 0 6px">人员</span>
      <el-select
        v-model="queryUser"
        filterable
        size="mini"
        style="width: 150px"
      >
        <el-option
          v-for="user in userList"
          :key="user.id"
          :value="user.id"
          :label="user.admin_name"
        ></el-option>
      </el-select>
      <span style="margin: 0 6px">品种</span>
      <el-select
        v-model="varietyEn"
        filterable
        size="mini"
        style="width: 150px"
      >
        <el-option
          v-for="v in varietyList"
          :key="v.variety_en"
          :value="v.variety_en"
          :label="v.variety_name"
        ></el-option>
      </el-select>
      <span style="margin-left: 8px">
        <el-button
          size="mini"
          type="primary"
          :loading="indexLoading"
          @click="toQueryUserIndex">
          查询
        </el-button>
      </span>
      <el-table>
      </el-table>
  </div>
</template>
<script>
  let NAME_SPACE = 'V03'
  import IndexDetaiPopup from '@/components/DataIndex'
  import { GetRuizyVariety } from '@/api/systemManage/variety'
  import { getAnalystList } from '@/api/user'
  import { getPersonalIndexes } from '@/api/edbdata/personal'
  export default {
    components: {
      IndexDetaiPopup,
    },
    data() {
      return {
        queryUser: null,
        varietyEn: '0',
        page: 1,
        pageSize: 30,
        totalCount: 0,
        indexLoading: false,
        userList: [],
        varietyList: [],
        indexesList: [],

      }
    },
    mounted() {
      getAnalystList().then((res) => {
        this.userList = res.data
        if (this.userList.length > 0) {
          this.queryUser = this.userList[0].id
          this.queryData()
        }
      })
      GetRuizyVariety(NAME_SPACE).then((res) => {
        this.varietyList = res.data
        this.varietyList.splice(0, 0, { variety_en: '0', variety_name: '全部' })
      })
    },
    methods: {
      queryData() {
        this.indexLoading = true
        getPersonalIndexes(
          this.queryUser,
          this.varietyEn,
          this.page,
          this.pageSize
        )
          .then((res) => {
            const data = res.data
            this.indexesList = data.data
            this.totalCount = data.total_count
            this.indexLoading = false
          })
          .catch(() => {
            this.indexLoading = fasle
          })
      },

      toQueryUserIndex() {
        this.page = 1
        this.queryData()
      },

    },
  }
</script>
<style scoped lang="scss">

</style>
